
<template>
  <div id = "app">
    <p style = "font-size:25px;">计数器: {{ counter }}</p>
    <button @click = "counter++" style = "font-size:25px;">点我</button>
  </div>
</template>

<script>
    export default {
        name: "watch",
      el: '#app',
      data() {
        return {counter: 1}
      },
      watch:{
        counter(curVal,oldVal){
          alert('计数器值的变化 :' + oldVal + ' 变为 ' + curVal + '!');
        }
      }
    }

</script>

<style scoped>

</style>
